<template>
  <div class="index">
    <!-- 顶部 -->
    <div class="top"><Admin></Admin></div>
    <!-- bottom -->
    <div class="bottom">
      <div class="left"><SideNav></SideNav></div>
      <div class="right">
        <div class="content">
          <el-scrollbar style="height: 100%;">
            <!-- 当前位置 -->
            <div class="current_position">
              <p class="breadcrumb">当前位置 :</p>
              <el-breadcrumb separator="/">
                <el-breadcrumb-item class="up">用户相关</el-breadcrumb-item>
                <el-breadcrumb-item class="up"><a @click="goTo('/AgencyList')">代理列表</a></el-breadcrumb-item>
                <el-breadcrumb-item>查看</el-breadcrumb-item>
              </el-breadcrumb>
            </div>
            <!-- 用户信息 -->
            <div class="userinformation">
              <div class="title">账号信息</div>
              <div class="message">
                <p><span>代理ID :</span><span>{{userinformation.id}}</span></p>
                <p><span>真实姓名 :</span><input class="input" type="text" v-model="userinformation.userRealName"></p>
                <!-- <p><span>账号 :</span><input type="text" v-model="userinformation.userName" class="input"></p> -->
                <!-- <p><span>密码 :</span><input type="text" v-model="userinformation.userName" class="input"></p> -->
                <p>
                  <span>认证状态 :</span>
                  <span>
                    <el-radio-group v-model="userinformation.userStatus">
                      <el-radio :label="1">已认证</el-radio>
                      <el-radio :label="2">未认证</el-radio>
                    </el-radio-group>
                  </span>
                </p>
                <p>
                  <span>账号状态 :</span>
                  <span>
                    <el-radio-group v-model="userinformation.enable">
                      <el-radio :label="1">正常</el-radio>
                      <el-radio :label="2">禁用</el-radio>
                      <el-radio :label="3">已注销</el-radio>
                    </el-radio-group>
                  </span>
                </p>
                <p><span></span><span><el-button @click="saveMessage()">保存</el-button></span></p>
              </div>
            </div>
          </el-scrollbar>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  let moment = require("moment")
  import Admin from '@/components/Admin.vue'
  import SideNav from '@/components/SideNav.vue'
  export default {
    name: 'AgencyListDetails',
    components:{
      Admin,
      SideNav
    },
    data () {
      return {
        id: '',//会员id
        userinformation:'',//会员信息
        status: 3,//账号状态
      }
    },
    mounted() {
      // 取到路由带过来的参数
      this.id = JSON.parse(JSON.stringify(this.$route.query.data.id));
      console.log(this.id);
      this.getUserListDetails();
    },
    // 时间格式过滤
    filters: {
      dateForma(dataStr, pattern = 'YYYY-MM-DD HH:mm:ss') {
        return moment(dataStr).format(pattern)
      }
    },
    methods: {
      // 路由
      goTo(path) {
        this.$router.push(path);
      },
      // 根据id查询会员详情
      getUserListDetails(){
        this.$axios.post(this.baseURL+'user/info',{
          "id": this.id,
          "requestSource":"PC"
        }).then((res)=>{
          console.log(res,"根据id 查询会员详情");
          if(res.data.code==1){
            this.userinformation = res.data.data;
          }
        }).catch((err)=>{
          console.log('request fail', err);
        })
      },
      // 保存修改
      saveMessage(){
        this.$axios.post(this.baseURL+'user/updateUserInfo',{
          "id":this.userinformation.id,
          "userRealName":this.userinformation.userRealName,
          "userStatus":this.userinformation.userStatus,
          "enable": this.userinformation.enable,
          "requestSource":"PC"
        }).then((res)=>{
          if(res.data.code==1){
            this.$message({
              message: '保存成功',
              type: 'success'
            });
            this.$router.go(-1);//返回上一层
          }
        }).catch((err)=>{
          console.log('request fail', err);
        })
      },
      // 查看充值记录
      goToRecord(){
        this.$router.push({
          path: '/RechargeRecord',
          query: {
            data: this.id,
          }
        })
      }
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
  @import '@/assets/css/index.scss'; //这个分号一定要写，要不会报错
  @import '@/assets/css/user.scss'; //这个分号一定要写，要不会报错
  .reset{
    color: #409EFF;
    font-size: 10px;
  }
  .message{
    position: relative;
    .input{
      height: 25px;
      margin-left: 30px;
      border: #d6d4d4 1px solid;
      padding-left: 5px;
    }
  }
</style>
